// TSSrv.cpp : Implementation of WinMain


#include "stdafx.h"
#include "resource.h"
#include "TSSrv_i.h"


#include "sqlquerybuilder.h"
#include "dbhelper.h"
#include "Query.h"
#include "SqlQueryBuilder.h"

class CTSSrvModule : public CAtlExeModuleT<CTSSrvModule>
{
public :
	DECLARE_LIBID(LIBID_TSSrv)
	DECLARE_REGISTRY_APPID_RESOURCEID(IDR_TSSRV, "{98DA8CCE-665E-4796-81D6-C81C176F06B7}")
	HRESULT InitializeSecurity() throw()
	{/*
		SOLE_AUTHENTICATION_SERVICE asAuthSvc;
		asAuthSvc.dwAuthnSvc = RPC_C_AUTHN_GSS_KERBEROS;
		asAuthSvc.dwAuthzSvc = RPC_C_AUTHZ_NAME;
		asAuthSvc.pPrincipalName = NULL;

		CoInitializeSecurity(NULL, 1, &asAuthSvc, NULL, RPC_C_AUTHN_LEVEL_PKT, RPC_C_IMP_LEVEL_IDENTIFY, NULL, NULL, NULL);*/
		// TODO : Call CoInitializeSecurity and provide the appropriate security settings for 
		// your service
		// Suggested - PKT Level Authentication, 
		// Impersonation Level of RPC_C_IMP_LEVEL_IDENTIFY 
		// and an appropiate Non NULL Security Descriptor.

		return S_OK;
	}
};

CTSSrvModule _AtlModule;


int n;
//
extern "C" int WINAPI _tWinMain(HINSTANCE /*hInstance*/, HINSTANCE /*hPrevInstance*/, 
                                LPTSTR /*lpCmdLine*/, int nShowCmd)
{

	//MSXML2::IXMLDOMDocumentPtr spXSD;

	//	
	//	HRESULT hr = spXSD.CreateInstance(__uuidof(MSXML2::DOMDocument60));

 //   _bstr_t sq;
	//CSqlQueryBuilder::GetInstance().GetSqlString(tsDatastoreItemTypeTestcase, L"<Query><Group GroupOperator=\"And\"><Expression Column=\"Id\" Operator=\"equals\">123</Expression><Expression Column=\"Id\" Operator=\"equals\">123</Expression></Group></Query>", sq);

//	_RecordsetPtr spRecSet;
//	spRecSet.CreateInstance(__uuidof(Recordset));
//
//	spRecSet->CursorLocation = adUseClient;
//
//
//	CDBHelper::GetInstance().Connect(L"hb-rtc-srv", L"TestStudio");
//
//	_RecordsetPtr spRecs;
//
//	
//	CDBHelper::GetInstance().ExecuteText(L"Select abc from test", spRecs);
//	
//
//	
//	VARIANT_BOOL b = spRecs->BOF;
//	_bstr_t b1 = spRecs->Fields->Item["abc"]->Value.bstrVal;	//a
//	spRecs->Move(1);
//	_bstr_t b2 = spRecs->Fields->Item["abc"]->Value.bstrVal;	//b
//	spRecs->Move(1);
//	_bstr_t b3 = spRecs->Fields->Item["abc"]->Value.bstrVal;	//c
//	spRecs->Sort = L"abc ASC";
//	spRecs->Move(1);
//	_bstr_t b4 = spRecs->Fields->Item["abc"]->Value.bstrVal;
//	spRecs->Move(1);
//	_bstr_t b5 = spRecs->Fields->Item["abc"]->Value.bstrVal;
//
//	
//	
//	
//
//	while(!spRecs->adoEOF)
//	{
//		LARGE_INTEGER liStart, liFinish;
//	QueryPerformanceCounter(&liStart);
//	//	//BSTR v = spRecs->Fields->Item["abc"]->Value.bstrVal;
//		 spRecs->Move(1000);
////		 QueryPerformanceCounter(&liFinish);
////	
////	LARGE_INTEGER liFreq;
////
////    QueryPerformanceFrequency(&liFreq);
////	float f = (float)(liFinish.LowPart - liStart.LowPart)/(float)liFreq.LowPart;
////int x=0;
//	}
////	


	//CAtlStringW strT;
	//strT.Format(L"%%s", L"xxx");
	//_bstr_t sql;
	//CSqlQueryBuilder qb(QueryTypeTestCase, L"<Group GroupOperator=\"And\"><Expression Column=\"Title\" FieldType=\"16\" Operator=\"equals\"><String>1</String></Expression><Expression Column=\"Title\" FieldType=\"16\" Operator=\"notEquals\"><String>123</String></Expression><Expression Column=\"Title\" FieldType=\"16\" Operator=\"contains\"><String>123</String></Expression><Expression Column=\"Title\" FieldType=\"16\" Operator=\"notContains\"><String>123</String></Expression><Expression Column=\"ID\" FieldType=\"32\" Operator=\"less\"><Number>123</Number></Expression><Expression Column=\"ID\" FieldType=\"32\" Operator=\"greater\"><Number>123</Number></Expression><Expression Column=\"ID\" FieldType=\"32\" Operator=\"equalsLess\"><Number>123</Number></Expression><Expression Column=\"ID\" FieldType=\"32\" Operator=\"equalsGreater\"><Number>123</Number></Expression><Expression Column=\"TreeID\" FieldType=\"32\" Operator=\"under\"><Number>2617</Number></Expression><Expression Column=\"TreeID\" FieldType=\"32\" Operator=\"equals\"><Number>2617</Number></Expression><Expression Column=\"TreeID\" FieldType=\"32\" Operator=\"notUnder\"><Number>2617</Number></Expression><Expression Column=\"TreeID\" FieldType=\"32\" Operator=\"notEquals\"><Number>2617</Number></Expression></Group>");
	//qb.GetSqlString(sql);
    return _AtlModule.WinMain(nShowCmd);
}

